<template>

	<view class="content CommissionRank">
		<view class="header">
			<view class="rank" v-if="position">{{(`Your current ranking`)}}<text class="num">{{ position + 1 }}</text></view>
			<view class="rank" v-else>{{(`You are currently not ranked`)}}</view>
		</view>
		<view class="wrapper">
			<view class="list">
				<view class="item acea-row row-between-wrapper" v-for="(item,index) in rankList" :key="index">
					<view class="num" v-if="index <= 2">
						<image :src="'../../static/images/medal0'+(index+1)+'.png'"></image>
					</view>
					<view class="num more-num" v-else>
						{{index+1}}
					</view>
					<view class="rankListView">
						<view class="picTxt acea-row row-between-wrapper">
							<view class="pictrue">
								<image :src="item.avatar"></image>
							</view>
							<view class="text line1">{{(item.nickname)}}</view>
						</view>
						<view class="people font-color">{{item.sum}}</view>
					</view>

				</view>
			</view>
		</view>

	</view>


</template>

<script>
	import {
		gtMonthRank
	} from '@/api/balance.js'
	export default {


		data() {
			return {
				rankList: [],


				loginInfo: JSON.parse(uni.getStorageSync('loginInfo')),
				position: 0,

			};
		},
		onLoad() {
			this.getList()
		},
		onReady() {

			uni.setNavigationBarColor({
				frontColor: '#fff',
				backgroundColor: '#333'
			})
		},
		methods: {
			getList() {
				gtMonthRank().then(res => {
					console.log(res);
					if (res.code == 0) {
						console.log(this.loginInfo);
					this.position = res.data.findIndex(item =>{
						return item.phone == this.loginInfo.username
					})
						this.rankList = res.data
					}
				})
			},
		},

	}
</script>

<style scoped lang="scss">
	.CommissionRank .header {
		background: url("") no-repeat;
		width: 100%;
		height: 344rpx;
		background-size: 100% 100%;
		background-color: #333;
	}


	.CommissionRank .header .rank {
		font-size: 33rpx;
		color: #fff;
		position: absolute;
		top: 160rpx;
		left: 48rpx;
		display: flex;
		align-items: baseline;
	}

	.CommissionRank .header .rank .num {
		font-size: 51rpx;
		font-weight: bold;
		margin: 0 10rpx;
		line-height: 51rpx;

		span {
			line-height: 51rpx;
		}
	}

	.CommissionRank .wrapper {
		width: 710rpx;
		background-color: #fff;
		border-radius: 20rpx;
		margin: -76rpx auto 0 auto;
	}

	.CommissionRank .wrapper .nav {
		height: 99rpx;
		border-bottom: 2.5rpx solid #f3f3f3;
		font-size: 30rpx;
		font-weight: bold;
		color: #999;
		line-height: 99rpx;
	}

	.CommissionRank .wrapper .nav .item.font-color {
		border-bottom: 4rpx solid #333;
	}

	.CommissionRank .wrapper .nav .item.fontcolor {
		color: #333;
		border-bottom: 4rpx solid #333;
	}

	.CommissionRank .wrapper .list {
		padding: 0 30rpx;
		overflow-y: auto;
		max-height: calc(100vh - 168px);
	}

	.CommissionRank .wrapper .list .item {
		border-bottom: 1px solid #f3f3f3;
		height: 128rpx;
		font-size: 28rpx;
	}

	.CommissionRank .wrapper .list .item .num {
		color: #666;
		width: 70rpx;
	}

	.CommissionRank .wrapper .list .item .num.more-num {
		padding-left: 8rpx;
	}

	.CommissionRank .wrapper .list .item .num image {
		width: 34rpx;
		height: 40rpx;
		display: block;
	}

	.CommissionRank .wrapper .list .item .rankListView {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.CommissionRank .wrapper .list .item .picTxt {
		display: flex;
		align-items: center;
		width: 350rpx;
	}

	.CommissionRank .wrapper .list .item .picTxt .pictrue {
		width: 68rpx;
		height: 68rpx;
	}

	.CommissionRank .wrapper .list .item .picTxt .pictrue image {
		width: 100%;
		height: 100%;
		display: block;
		border-radius: 50%;
	}

	.CommissionRank .wrapper .list .item .picTxt .text {
		width: 262rpx;
		color: #333;
	}

	.CommissionRank .wrapper .list .item .people {
		width: 175rpx;
		text-align: right;
		font-weight: 600;
	}
</style>